from part import *
from material import *
from section import *
from assembly import *
from step import *
from interaction import *
from load import *
from mesh import *
from optimization import *
from job import *
from sketch import *
from visualization import *
from connectorBehavior import *
from math import *
import random


#define the material
List = [['Beiban',0.075,[4200.0, 0.32]],['OCA4',0.025,[0.01061, -0.00012, 1.7318e-06, 4.79455, 0.0, 0.0]],
    ['Jiban',0.02,[9100.0, 0.33]],['OCA3',0.015,[0.01061, -0.00012, 1.7318e-06, 4.79455, 0.0, 0.0]],['Xianshi',0.04,[49000.0, 0.30]],
    ['OCA2',0.025,[0.01061, -0.00012, 1.7318e-06, 4.79455, 0.0, 0.0]],['Pianguang',0.05,[3769.0, 0.33]],
    ['OCA1',0.03,[0.01061, -0.00012, 1.7318e-06, 4.79455, 0.0, 0.0]],['Gaiban',0.06,[5600.0, 0.29]]]


#define the depth to change of each layer
Changelist =[[0.030,0.105,0.03],[0.090,0.045,0.03]]

#define the heightlist or height ball to fall
heightlist = [25,50,100,150]
height = 25

#define the total time
timeall = 0.01  #0.006

#gravity
g = 9800
#time each step
timestep = 2e-8
#mash of ball
ballmesh = 128
#mash of layer
cengmesh = 0.015


#make a data which depth is ramdom
def ramdommake(num):
    changelist=[]
    for i in range(num):
        gai = random.randrange(20,105)
        oca = random.randrange(20,60)
        bei = 165-gai-oca
        list = [gai,bei,oca]
        changelist.append(list)
    return changelist

#make a layer from matrial matrix
def modelmake(setname,setdepth):
    mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=200.0)
    mdb.models['Model-1'].sketches['__profile__'].rectangle(point1=(-75, setdepth), 
        point2=(75, 0.0))
    mdb.models['Model-1'].Part(dimensionality=TWO_D_PLANAR, name= setname , type=
        DEFORMABLE_BODY)
    mdb.models['Model-1'].parts[setname].BaseShell(sketch=
        mdb.models['Model-1'].sketches['__profile__'])

#make a ball
def ballmake():
    mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=200.0)
    mdb.models['Model-1'].sketches['__profile__'].CircleByCenterPerimeter(center=(
        0.0, 0.0), point1=(7.5, 0))
    mdb.models['Model-1'].Part(dimensionality=TWO_D_PLANAR, name='Ball', type=
        DEFORMABLE_BODY)
    mdb.models['Model-1'].parts['Ball'].BaseShell(sketch=
        mdb.models['Model-1'].sketches['__profile__'])

#assemble
def assemble(setname):
    mdb.models['Model-1'].rootAssembly.Instance(dependent=OFF, name=setname, 
         part=mdb.models['Model-1'].parts[setname])

#change layer
for k in range (len(Changelist)):
    List[8][1] = Changelist[k][0]
    List[0][1] = Changelist[k][1]
    List[7][1] = Changelist[k][2]

#make model
    for i in range (len(List)):
        modelmake(List[i][0],List[i][1])
    ballmake()

    mdb.models['Model-1'].rootAssembly.DatumCsysByDefault(CARTESIAN)

#assmeble
    for i in range (len(List)):
        assemble(List[i][0])
    assemble('Ball')

    nums=0

#move layer
    for i in range (len(List)-1):
        num = float(List[i][1])
        nums += num
        mdb.models['Model-1'].rootAssembly.translate(instanceList=(List[i+1][0], ), 
        vector=(0.0, nums, 0.0))

#define contact of Softcontact
    mdb.models['Model-1'].rootAssembly.translate(instanceList=('Ball', ), 
        vector=(0.0, 7.9 , 0.0))
    mdb.models['Model-1'].ContactProperty('IntProp-1')
    mdb.models['Model-1'].interactionProperties['IntProp-1'].TangentialBehavior(
        dependencies=0, directionality=ISOTROPIC, elasticSlipStiffness=None, 
        formulation=PENALTY, fraction=0.005, maximumElasticSlip=FRACTION, 
        pressureDependency=OFF, shearStressLimit=None, slipRateDependency=OFF, 
        table=((0.3, ), ), temperatureDependency=OFF)

#define contact of Hardcontact
    mdb.models['Model-1'].interactionProperties['IntProp-1'].NormalBehavior(
        allowSeparation=ON, constraintEnforcementMethod=DEFAULT, 
        pressureOverclosure=HARD)
    mdb.models['Model-1'].ContactProperty('IntProp-2')
    mdb.models['Model-1'].interactionProperties['IntProp-2'].TangentialBehavior(
        dependencies=0, directionality=ISOTROPIC, elasticSlipStiffness=None, 
        formulation=PENALTY, fraction=0.005, maximumElasticSlip=FRACTION, 
        pressureDependency=OFF, shearStressLimit=None, slipRateDependency=OFF, 
        table=((0.3, ), ), temperatureDependency=OFF)


#make contact or tie on each layer
    for i in range(len(List)-1):
        mdb.models['Model-1'].rootAssembly.Surface(name='m_Surf-%d'%(i+1), side1Edges=
            mdb.models['Model-1'].rootAssembly.instances[List[i][0]].edges.getSequenceFromMask(
            ('[#1 ]', ), ))
        mdb.models['Model-1'].rootAssembly.Surface(name='s_Surf-%d'%(i+1), side1Edges=
            mdb.models['Model-1'].rootAssembly.instances[List[i+1][0]].edges.getSequenceFromMask(
            ('[#4 ]', ), ))

        # mdb.models['Model-1'].SurfaceToSurfaceContactExp(clearanceRegion=None, 
        #     createStepName='Initial', datumAxis=None, initialClearance=OMIT, 
        #     interactionProperty='IntProp-1', master=
        #     mdb.models['Model-1'].rootAssembly.surfaces['m_Surf-%d'%(i+1)], 
        #     mechanicalConstraint=KINEMATIC, name='Int-%d'%(i+1), slave=
        #     mdb.models['Model-1'].rootAssembly.surfaces['s_Surf-%d'%(i+1)], sliding=FINITE)    #contact

        mdb.models['Model-1'].Tie(adjust=ON, master=
            mdb.models['Model-1'].rootAssembly.surfaces['m_Surf-%d'%(i+1)], name=
            'Constraint-%d'%(i+1), positionToleranceMethod=COMPUTED, slave=
            mdb.models['Model-1'].rootAssembly.surfaces['s_Surf-%d'%(i+1)], thickness=ON, 
            tieRotations=ON)          #tie


#make contact or tie on ball
    mdb.models['Model-1'].rootAssembly.Surface(name='Ball_surf', side1Edges=
        mdb.models['Model-1'].rootAssembly.instances['Ball'].edges.getSequenceFromMask(
        ('[#1 ]', ), ))
    mdb.models['Model-1'].rootAssembly.Surface(name='Gai_surf', side1Edges=
        mdb.models['Model-1'].rootAssembly.instances['Gaiban'].edges.getSequenceFromMask(
        ('[#1 ]', ), ))
    mdb.models['Model-1'].SurfaceToSurfaceContactExp(clearanceRegion=None, 
        createStepName='Initial', datumAxis=None, initialClearance=OMIT, 
        interactionProperty='IntProp-2', master=
        mdb.models['Model-1'].rootAssembly.surfaces['Ball_surf'], 
        mechanicalConstraint=KINEMATIC, name='Int-9', slave=
        mdb.models['Model-1'].rootAssembly.surfaces['Gai_surf'], sliding=FINITE)


#material define
    mdb.models['Model-1'].Material(name = 'Ball')
    mdb.models['Model-1'].materials['Ball'].Elastic(table=((2.1e5,0.3), ))
    mdb.models['Model-1'].materials['Ball'].Density(table=((79e-10, ), ))  

    for i in range(len(List)):
        if List[i][0] in ['Gaiban','Pianguang','Xianshi','Jiban','Beiban']:
            mdb.models['Model-1'].Material(name = List[i][0])
            mdb.models['Model-1'].materials[List[i][0]].Elastic(table=((List[i][2]), ))
            mdb.models['Model-1'].materials[List[i][0]].Density(table=((9e-10, ), ))  
        if List[i][0] in ['OCA1','OCA2','OCA3','OCA4']:
            mdb.models['Model-1'].Material(name = List[i][0])
            mdb.models['Model-1'].materials[List[i][0]].Hyperelastic(materialType=
                ISOTROPIC, table=((0.01061, -0.00012, 1.7318e-06, 4.79455, 0.0, 0.0), ), 
                testData=OFF, type=YEOH, volumetricResponse=VOLUMETRIC_DATA)
            mdb.models['Model-1'].materials[List[i][0]].Density(table=((9e-10, ), ))  
            mdb.models['Model-1'].materials[List[i][0]].Viscoelastic(domain=
                FREQUENCY, frequency=PRONY, table=((0.5902, 0.0, 0.0188), (0.1461, 0.0, 
                0.2084), (0.1115, 0.0, 1.8675), (0.0643, 0.0, 19.167), (0.0352, 0.0, 
                233.07)))        

    for i in range(len(List)):
        mdb.models['Model-1'].HomogeneousSolidSection( material= List[i][0] , name=
        List[i][0] , thickness=None)

        mdb.models['Model-1'].parts[List[i][0]].Set(faces=
            mdb.models['Model-1'].parts[List[i][0]].faces.getSequenceFromMask(('[#1 ]', 
            ), ), name= List[i][0])
        mdb.models['Model-1'].parts[List[i][0]].SectionAssignment(offset=0.0, 
            offsetField='', offsetType=MIDDLE_SURFACE, region=
            mdb.models['Model-1'].parts[List[i][0]].sets[List[i][0]], sectionName=
            List[i][0] , thicknessAssignment=FROM_SECTION)

    mdb.models['Model-1'].HomogeneousSolidSection( material= 'Ball' , name=
        'Ball' , thickness=None)
    mdb.models['Model-1'].parts['Ball'].Set(faces=
        mdb.models['Model-1'].parts['Ball'].faces.getSequenceFromMask(('[#1 ]', 
        ), ), name= 'Ball')
    mdb.models['Model-1'].parts['Ball'].SectionAssignment(offset=0.0, 
        offsetField='', offsetType=MIDDLE_SURFACE, region=
        mdb.models['Model-1'].parts['Ball'].sets['Ball'], sectionName=
        'Ball' , thicknessAssignment=FROM_SECTION)
    
    

    #mesh

    mdb.models['Model-1'].rootAssembly.regenerate()
    mdb.models['Model-1'].rootAssembly.seedEdgeBySize(constraint=FINER, 
        deviationFactor=0.1, edges=
        mdb.models['Model-1'].rootAssembly.instances['Gaiban'].edges.getSequenceFromMask(
        mask=('[#f ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA1'].edges.getSequenceFromMask(
        mask=('[#f ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Pianguang'].edges.getSequenceFromMask(
        mask=('[#f ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA2'].edges.getSequenceFromMask(
        mask=('[#f ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Xianshi'].edges.getSequenceFromMask(
        mask=('[#f ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA3'].edges.getSequenceFromMask(
        mask=('[#f ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Jiban'].edges.getSequenceFromMask(
        mask=('[#f ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA4'].edges.getSequenceFromMask(
        mask=('[#f ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Beiban'].edges.getSequenceFromMask(
        mask=('[#f ]', ), ), size=cengmesh)
    mdb.models['Model-1'].rootAssembly.seedEdgeByNumber(constraint=FINER, edges=
        mdb.models['Model-1'].rootAssembly.instances['OCA1'].edges.getSequenceFromMask(
        ('[#2 ]', ), ), number=2)
    mdb.models['Model-1'].rootAssembly.seedEdgeByNumber(constraint=FINER, edges=
        mdb.models['Model-1'].rootAssembly.instances['OCA2'].edges.getSequenceFromMask(
        ('[#2 ]', ), ), number=2)
    mdb.models['Model-1'].rootAssembly.seedEdgeByNumber(constraint=FINER, edges=
        mdb.models['Model-1'].rootAssembly.instances['OCA3'].edges.getSequenceFromMask(
        ('[#2 ]', ), ), number=2)
    mdb.models['Model-1'].rootAssembly.seedEdgeByNumber(constraint=FINER, edges=
        mdb.models['Model-1'].rootAssembly.instances['OCA4'].edges.getSequenceFromMask(
        ('[#2 ]', ), ), number=2)
    
    mdb.models['Model-1'].rootAssembly.seedEdgeByNumber(constraint=FINER, edges=
        mdb.models['Model-1'].rootAssembly.instances['Ball'].edges.getSequenceFromMask(
        ('[#1 ]', ), ), number=ballmesh)
    mdb.models['Model-1'].rootAssembly.setMeshControls( regions=
        mdb.models['Model-1'].rootAssembly.instances['Ball'].faces.getSequenceFromMask(
        ('[#1 ]', ), ))
    mdb.models['Model-1'].rootAssembly.setMeshControls(regions=
        mdb.models['Model-1'].rootAssembly.instances['Gaiban'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA1'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Pianguang'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA2'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Xianshi'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA3'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Jiban'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA4'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Beiban'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), ))
    mdb.models['Model-1'].rootAssembly.generateMesh(regions=
        mdb.models['Model-1'].rootAssembly.instances['Gaiban'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA1'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Pianguang'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA2'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Xianshi'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA3'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Jiban'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA4'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Beiban'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), ))
    mdb.models['Model-1'].rootAssembly.generateMesh(regions=
        mdb.models['Model-1'].rootAssembly.instances['Ball'].faces.getSequenceFromMask(
        ('[#1 ]', ), ))


    mdb.models['Model-1'].ExplicitDynamicsStep(improvedDtMethod=ON, name='Step-1', 
        previous='Initial', timePeriod=timeall)

    mdb.models['Model-1'].rootAssembly.Set(edges=
        mdb.models['Model-1'].rootAssembly.instances['Gaiban'].edges.getSequenceFromMask(
        mask=('[#2 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Beiban'].edges.getSequenceFromMask(
        mask=('[#2 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA4'].edges.getSequenceFromMask(
        mask=('[#2 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Jiban'].edges.getSequenceFromMask(
        mask=('[#2 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA3'].edges.getSequenceFromMask(
        mask=('[#2 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Xianshi'].edges.getSequenceFromMask(
        mask=('[#2 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA2'].edges.getSequenceFromMask(
        mask=('[#2 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Pianguang'].edges.getSequenceFromMask(
        mask=('[#2 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA1'].edges.getSequenceFromMask(
        mask=('[#2 ]', ), ), name='Set-45')
    mdb.models['Model-1'].EncastreBC(createStepName='Step-1', localCsys=None, 
        name='BC-4', region=mdb.models['Model-1'].rootAssembly.sets['Set-45'])
    mdb.models['Model-1'].rootAssembly.Set(edges=
        mdb.models['Model-1'].rootAssembly.instances['Gaiban'].edges.getSequenceFromMask(
        mask=('[#8 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA1'].edges.getSequenceFromMask(
        mask=('[#8 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Pianguang'].edges.getSequenceFromMask(
        mask=('[#8 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA2'].edges.getSequenceFromMask(
        mask=('[#8 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Xianshi'].edges.getSequenceFromMask(
        mask=('[#8 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA3'].edges.getSequenceFromMask(
        mask=('[#8 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Jiban'].edges.getSequenceFromMask(
        mask=('[#8 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['OCA4'].edges.getSequenceFromMask(
        mask=('[#8 ]', ), )+\
        mdb.models['Model-1'].rootAssembly.instances['Beiban'].edges.getSequenceFromMask(
        mask=('[#8 ]', ), ), name='Set-46')
    mdb.models['Model-1'].EncastreBC(createStepName='Step-1', localCsys=None, 
        name='BC-5', region=mdb.models['Model-1'].rootAssembly.sets['Set-46'])

#Boundary conditions

    # mdb.models['Model-1'].rootAssembly.Set(edges=
    #     mdb.models['Model-1'].rootAssembly.instances['OCA4'].edges.getSequenceFromMask(
    #     mask=('[#2 ]', ), )+\
    #     mdb.models['Model-1'].rootAssembly.instances['OCA3'].edges.getSequenceFromMask(
    #     mask=('[#2 ]', ), )+\
    #     mdb.models['Model-1'].rootAssembly.instances['OCA2'].edges.getSequenceFromMask(
    #     mask=('[#2 ]', ), )+\
    #     mdb.models['Model-1'].rootAssembly.instances['OCA1'].edges.getSequenceFromMask(
    #     mask=('[#2 ]', ), ), name='Set-45')
    # mdb.models['Model-1'].EncastreBC(createStepName='Step-1', localCsys=None, 
    #     name='BC-4', region=mdb.models['Model-1'].rootAssembly.sets['Set-45'])
    # mdb.models['Model-1'].rootAssembly.Set(edges=
    #     mdb.models['Model-1'].rootAssembly.instances['OCA1'].edges.getSequenceFromMask(
    #     mask=('[#8 ]', ), )+\
    #     mdb.models['Model-1'].rootAssembly.instances['OCA2'].edges.getSequenceFromMask(
    #     mask=('[#8 ]', ), )+\
    #     mdb.models['Model-1'].rootAssembly.instances['OCA3'].edges.getSequenceFromMask(
    #     mask=('[#8 ]', ), )+\
    #     mdb.models['Model-1'].rootAssembly.instances['OCA4'].edges.getSequenceFromMask(
    #     mask=('[#8 ]', ),),  name='Set-46')
    # mdb.models['Model-1'].EncastreBC(createStepName='Step-1', localCsys=None, 
    #     name='BC-5', region=mdb.models['Model-1'].rootAssembly.sets['Set-46'])    

    # mdb.models['Model-1'].rootAssembly.Set(edges=
    #     mdb.models['Model-1'].rootAssembly.instances['Beiban'].edges.getSequenceFromMask(
    #     ('[#4 ]', ), ), name='Set-66')
    # mdb.models['Model-1'].EncastreBC(createStepName='Step-1', localCsys=None, 
    #     name='BC-3', region=mdb.models['Model-1'].rootAssembly.sets['Set-66'])
    # mdb.models['Model-1'].DisplacementBC(amplitude=UNSET, createStepName='Step-1', 
    #     distributionType=UNIFORM, fieldName='', fixed=OFF, localCsys=None, name=
    #     'BC-3', region=mdb.models['Model-1'].rootAssembly.sets['Set-66'], u1=0.0, 
    #     u2=UNSET, ur3=0.0)                                                            


    mdb.models['Model-1'].DisplacementBC(amplitude=UNSET, createStepName='Step-1', 
        distributionType=UNIFORM, fieldName='', fixed=OFF, localCsys=None, name=
        'BC-2', region=Region(
        faces=mdb.models['Model-1'].rootAssembly.instances['Ball'].faces.getSequenceFromMask(
        mask=('[#1 ]', ), ), 
        edges=mdb.models['Model-1'].rootAssembly.instances['Ball'].edges.getSequenceFromMask(
        mask=('[#1 ]', ), )), u1=0.0, u2=UNSET, ur3=0.0)                  #ball 
 
    mdb.models['Model-1'].rootAssembly.Set(faces=
        mdb.models['Model-1'].rootAssembly.instances['Ball'].faces.getSequenceFromMask(
        ('[#1 ]', ), ), name='Set-10')
    mdb.models['Model-1'].Gravity(comp2=-g, createStepName='Step-1', 
        distributionType=UNIFORM, field='', name='Load-1', region=
        mdb.models['Model-1'].rootAssembly.sets['Set-10'])

    mdb.models['Model-1'].fieldOutputRequests['F-Output-1'].setValues(numIntervals=
        1)
    mdb.models['Model-1'].steps['Step-1'].setValues(improvedDtMethod=ON, 
        massScaling= ((SEMI_AUTOMATIC, MODEL, THROUGHOUT_STEP, 0.0, timestep, 
         BELOW_MIN, 1, 0, 0.0, 0.0, 0, None), ))
 

    mdb.models['Model-1'].rootAssembly.Set(faces=
        mdb.models['Model-1'].rootAssembly.instances['Ball'].faces.getSequenceFromMask(
        ('[#1 ]', ), ), name='Set-23')

    mdb.models['Model-1'].Velocity(distributionType=MAGNITUDE, field='', name=
        'Predefined Field-1', omega=0.0, region=
        mdb.models['Model-1'].rootAssembly.sets['Set-23'], velocity2=-sqrt(2*g*height))

#submit your job
    mdb.Job(activateLoadBalancing=False, atTime=None, contactPrint=OFF, 
    description='', echoPrint=OFF, explicitPrecision=SINGLE, historyPrint=OFF, 
    memory=90, memoryUnits=PERCENTAGE, model='Model-1', modelPrint=OFF, 
    multiprocessingMode=DEFAULT, name='gai3-%d'%(k), nodalOutputPrecision=SINGLE, 
    numCpus=16, numDomains=16, parallelizationMethodExplicit=DOMAIN, queue=None, 
    resultsFormat=ODB, scratch='', type=ANALYSIS, userSubroutine='', waitHours=
    0, waitMinutes=0)

    mdb.jobs['gai3-%d'%(k)].submit(consistencyChecking=OFF)




#different height
    # for i in heightlist:

    #     mdb.models['Model-1'].Velocity(distributionType=MAGNITUDE, field='', name=
    #     'Predefined Field-1', omega=0.0, region=
    #     mdb.models['Model-1'].rootAssembly.sets['Set-23'], velocity2=-sqrt(2*g*i))

    #     mdb.Job(activateLoadBalancing=False, atTime=None, contactPrint=OFF, 
    #     description='', echoPrint=OFF, explicitPrecision=SINGLE, historyPrint=OFF, 
    #     memory=90, memoryUnits=PERCENTAGE, model='Model-1', modelPrint=OFF, 
    #     multiprocessingMode=DEFAULT, name='height1-%d'%(i), nodalOutputPrecision=SINGLE, 
    #     numCpus=16, numDomains=16, parallelizationMethodExplicit=DOMAIN, queue=None, 
    #     resultsFormat=ODB, scratch='', type=ANALYSIS, userSubroutine='', waitHours=
    #     0, waitMinutes=0)

    #     mdb.jobs['height1-%d'%(i)].submit(consistencyChecking=OFF)


    